/*!
\copyright  Copyright (c) 2019 - 2023 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\file
\brief      Common header file pre-included as part of project builds.

    This file contains defines and macros common across the ADK builds.

    The file was created to deal with some mismatches when moving from 
    earlier chips which had a different architecture.

    It is included into all of the VM libs with -preinclude.
*/


#ifndef _HYDRA_DEV_H
#define _HYDRA_DEV_H

#include <trapsets.h>
#include <file.h>
#include <pio.h>

typedef uint16 pskey;


#define checkDUTKeyRelease(x, y) ((void)0)
#define checkDUTKeyPress(x) ((void)0)


/* Needed for VM library builds */
#define PIOS_PER_BANK 32U

/* memcmp8 is specific to the XAP processor, comparing just 
   8 bits of each element in a "uint8" (which is 16 bits 
   on the XAP processor).  As we only have 8 bits in each element,
   we can use the standard memcmp */
#define memcmp8(x, y, z) memcmp((x),(y),(z))

/*  Previous architecture had a minimum addressable unit of 16bits and the basic compare
    and find functions compared based on 16-bit units.
    Map these functions to the 'byte' version */
#define UtilCompare(A, B, C) UtilCompareByte((const uint8*)(A), (const uint8*)(B), (C))
#define UtilFind(A, B, C, D, E, F) UtilFindByte((uint8)(A), (uint8)(B), (const uint8*)(C), (D), (E), (F))

/* Macros to standardise pragma usage.

    _Pragma() can be used in macros, whereas #pragma cannot.
    This allows pragmas to be applied dependent on compiler, without the need to disable
    unknown pragma warnings or include #if conditions in code
 */

/*! PRAGMA: place definitions into a specially named section.
    This can be used to group similar data when linking */
#if defined(__KALIMBA__)
#define KEEP KEEP_PM
#define SECTION_PRAGMA(x) _Pragma(#x)	
#define DATASECTION(x) SECTION_PRAGMA(datasection x)
#define UNITCODESECTION(x) SECTION_PRAGMA(unitcodesection x)
#define UNITSUPPRESS_UNUSED() _Pragma("unitsuppress Unused")
#elif defined(__GNUC__) && !defined(__clang__)
#define KEEP "debug_functions"
#define DATASECTION(x) __attribute__((section(#x)))	
#define UNITCODESECTION(x) __attribute__((section (x)))
#define UNITSUPPRESS_UNUSED() _Pragma("GCC diagnostic ignored \"-Wunused\"")
#else
#define KEEP "debug_functions"
#define SECTION_PRAGMA(x) _Pragma(#x)
#define DATASECTION(x) __attribute__((section(#x)))	
#define UNITCODESECTION(x) SECTION_PRAGMA(clang section text = x)
#define UNITSUPPRESS_UNUSED() _Pragma("clang diagnostic ignored \"-Wunused\"")
#endif

/*! PRAGMA: disable warning for unused const variable.
    This only affects files including this macro */
#if defined(__KALIMBA__)
#define DISABLE_WARNING_UNUSED_CONST() 
#else
#define DISABLE_WARNING_UNUSED_CONST() _Pragma("clang diagnostic ignored \"-Wunused-const-variable\"") 
#endif

/*! PRAGMA: disable warning for unused declaration.
    If supported, this will only affect the object following this macro,
    otherwise the warning will be suppressed for the entire file */
#if defined(__KALIMBA__)
#define DISABLE_WARNING_UNUSED() _Pragma("unitsuppress Unused")
#else
#define DISABLE_WARNING_UNUSED() __attribute__((unused)) 
#endif


#endif /*_HYDRA_DEV_H*/
